from bs4 import BeautifulSoup
import requests
from constants.url_58 import *
from util.common_util import print_line


def get_channel(channel_url, headers):
    print_line("get_channel")
    print("get_channel, channel_url:{}, headers:{}".format(channel_url, headers))

    response = requests.get(channel_url, headers=headers)
    soup = BeautifulSoup(response.text, 'lxml')

    channel_a_list = soup.select('#ymenu-side > ul > li > ul > li > b > a')
    channel_urls = []
    for channel_a in channel_a_list:
        channel_href = channel_a.get('href')
        if channel_href is not None and channel_href not in channel_urls:
            channel_urls.append(channel_href)
    return channel_urls


if __name__ == '__main__':
    channel_urls = get_channel(channel_url,headers)
    for channel_url in channel_urls:
        print(channel_url)